<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('试题列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>试题名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li class="select-time">
                                <label>创建时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                            </li>
                            <li>
                                <label>试题类型：</label>
                                <select name="type" th:with="type=${@dict.getType('sc_exam_question_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>年级：</label>
                                <select name="gradeId" th:with="type=${@grade.getGradeList()}">
                                    <option value="">所有</option>
                                    <option th:each="grade : ${type}" th:text="${grade.gradeName}" th:value="${grade.id}"></option>
                                </select>
                            </li>

                            <li>
                                <label>学科：</label>
                                <select name="subject" th:with="type=${@dict.getType('sc_subject_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>难度：</label>
                                <select name="difficulty" th:with="type=${@dict.getType('sc_exam_difficulty')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>


                            <li>
                                <label>学期：</label>
                                <select name="term" th:with="type=${@dict.getType('sc_term_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="school:question:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="school:question:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="school:question:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="school:question:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('school:question:edit')}]];
        var removeFlag = [[${@permission.hasPermi('school:question:remove')}]];
        var typeDatas = [[${@dict.getType('sc_exam_question_type')}]];
        var subjectDatas = [[${@dict.getType('sc_subject_type')}]];
        var difficultyDatas = [[${@dict.getType('sc_exam_difficulty')}]];
        var termDatas = [[${@dict.getType('sc_term_type')}]];
        var statusDatas = [[${@dict.getType('sys_data_status')}]];
        var prefix = ctx + "school/question";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                detailUrl: prefix + "/detail/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "试题",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id', 
                    title: 'id',
                    visible: false
                }/*,
                {
                    field: 'name', 
                    title: '试题名称'
                },
                {
                    field: 'type', 
                    title: '试题类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field: 'subject', 
                    title: '学科',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(subjectDatas, value);
                    }
                },
                {
                    field: 'gradeName', 
                    title: '年级名称'
                }*/,
                {
                    field: 'content', 
                    title: '内容',
                    formatter: function(value, row, index) {
                        var div = '<div style="max-width: 700px;max-height: 50px; white-space: nowrap;text-overflow:ellipsis;overflow: hidden;">'+value+'</div>';
                        return div;
                    }
                },
                {
                    field: 'difficulty', 
                    title: '难度',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(difficultyDatas, value);
                    }
                }, {
                    field: 'term',
                    title: '学期',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(termDatas, value);
                    }
                },
                {
                    field: 'score', 
                    title: '分数'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-eye"></i>预览</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="report(\'' + row.id + '\')"><i class="fa fa-eye"></i>统计</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });


        function preview(id) {
            var _width = $.common.isEmpty(width) ? "800" : width;
            var _height = $.common.isEmpty(height) ? ($(window).height() - 50) : height;
            //如果是移动端，就使用自适应大小弹窗
            if ($.common.isMobile()) {
                _width = 'auto';
                _height = 'auto';
            }
            var options = {
                title: table.options.modalName + "详细",
                width: _width,
                height: _height,
                url: "",
                skin: 'layui-layer-gray',
                btn: ['关闭'],
                yes: function (index, layero) {
                    layer.close(index);
                }
            };
            $.modal.openOptions(options);

        }

        function report(id) {

            //$.operate.addUrl("answer");
            $.modal.openTab("试题统计" , prefix + "/report/"+id);
        }
    </script>
</body>
</html>